package com.lzw.demo.surfaceviewdemo;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.lzw.demo.surfaceviewdemo.customview.MySurfaceView;
import com.lzw.demo.surfaceviewdemo.viewarch.CustomTextView;

public class MainActivity extends AppCompatActivity {

    private MySurfaceView mySurfaceView;

    private CustomTextView customTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mySurfaceView = new MySurfaceView(this);
        customTextView = new CustomTextView(this);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.gravity = Gravity.CENTER;
        customTextView.setLayoutParams(layoutParams);
        //如果是直接new 没有setLayoutParams,getMeasuredWidth 和getMeasuredHeight就是整个phone屏幕，
        customTextView.setText(String.format(getResources().getString(R.string.car_run_distance),3.43));
        setContentView(customTextView);
    }
}
